package com.xjc.business.controller.colladmin;

import com.xjc.business.entity.po.coladmin.ColAdminLoginPo;
import com.xjc.business.entity.po.schadmin.SchAdminLoginPo;
import com.xjc.business.entity.vo.coladmin.ColAdminLoginVo;
import com.xjc.business.entity.vo.schadmin.SchAdminLoginVo;
import com.xjc.business.service.CollegeAdminsService;
import com.xjc.system.constants.MyConstants;
import com.xjc.system.exception.MyException;
import com.xjc.system.result.Result;
import com.xjc.system.result.ResultCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 徐锦程
 * 时间:2025-01-29 10:27
 */
@RestController
@RequestMapping("/college_admin/user")
public class ColUserController {

    @Autowired
    CollegeAdminsService collegeAdminsService;

    /**
     * 登录
     * @param colAdminLoginPo 登录参数
     * @return 登录成功返回token，失败返回错误信息
     */
    @PostMapping("/login")
    public Result<ColAdminLoginVo> doLogin(@RequestBody(required = false) ColAdminLoginPo colAdminLoginPo){
        if(colAdminLoginPo == null || colAdminLoginPo.getUsername() == null || colAdminLoginPo.getPassword() == null){
            throw new MyException(ResultCode.SUCCESS.getCode(), MyConstants.PARAM_MISSING);
        }

        return collegeAdminsService.doLogin(colAdminLoginPo);
    }
}
